package ch.six4rty.doodle.utils
{
	import ch.six4rty.doodle.data.PollDataBuilderVO;
	
	import flash.xml.XMLDocument;
	
	import nl.demonsters.debugger.MonsterDebugger;

	public  class XMLConstructor
	{
		private static var _xml				:XML;
		private static var _xmlDoc			:XMLDocument;
		
		public static function comment( pName:String, pComment:String ):XML
		{
			_xml = new XML( "<comment xmlns='http://doodle.com/xsd1'><who>" + pName + "</who><what>" + pComment + "</what></comment>" );
			return _xml;
		}
		
		public static function participant( pName:String, optionArray:Array ):XML
		{
			var str:String;
			
			for ( var i:int = 0; i < optionArray.length; i++ )
			{
				str += "<option>" + optionArray[i] +"</option>";
			}
			
			var xml:XML = new XML( "<participant xmlns='http://doodle.com/xsd1'> <name>" + pName + "</name> <preferences>" + str + "</preferences> </participant>" );
			return xml;
		}
		
		public static function poll( pd:PollDataBuilderVO ):XML
		{
			var str:String;
			
			for (var i:int = 0; i < pd._options.length; ++i)
			{
				str += "<option>" + pd._options[i] +"</option>";
			}
			
			var xml:XML = new XML( "<poll xmlns='http://doodle.com/xsd1'><type>" + pd._type + "</type><hidden>" + pd._type + "</hidden><levels>" + pd._levels + "</levels><title>" + pd._title + "</title><description>" + pd._description + "</description><initiator><name>" + pd._initiator + "</name><eMailAddress>" + pd._initiatorEmail + "</eMailAddress></initiator><options>" + str + "</options></poll>");
			return xml;
		}
		
		
	}
}